<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/base/base.jsp" %>
<%@ include file="/base/database.jsp" %>

<%

  request.setCharacterEncoding("utf-8");

  String depID=request.getParameter("depID");
  String depName =request.getParameter("depName");

  StringBuffer sqlBuff=new StringBuffer();
  sqlBuff.append("insert into sys_department(depID,depName)values(?,?)");
  String sql=sqlBuff.toString();
  
  String url="jdbc:mysql://localhost:3306/leave";
  String user="root";
  String password="";
  Class.forName("com.mysql.jdbc.Driver"); 
  Connection conn=DriverManager.getConnection(url,user,password);
  PreparedStatement pstmt=conn.prepareStatement(sql);
   
 
  int parameterIndex=1;
  
  pstmt.setString(parameterIndex++, depID);
  pstmt.setNString(parameterIndex++, depName);
 
  int count=pstmt.executeUpdate();

  close(pstmt, conn);

  process(request, response, "department_list.jsp");

%>